﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Comm;

public partial class Web_Admin_SiteInfo_QQMSN_list : AdminPageBase
{
    private BQQMSN bll = new BQQMSN();
    protected void Page_Load(object sender, EventArgs e)
    {
        base.CheckPopedomInfoRedirect(1018, 1);
        but_enable.Enabled = but_disenable.Enabled = base.CheckPopedomInfo(1018, 64);
        but_delete.Enabled = base.CheckPopedomInfo(1018, 8);
        if (!IsPostBack)
        {
            loadData();
        }
    }

    /// <summary>
    /// 加载数据
    /// </summary>
    private void loadData()
    {
        List<MQQMSN> list = bll.getList("");
        rpList.DataSource = list;
        rpList.DataBind();
        lit_nodata.Visible = list == null || list.Count < 1 ? true : false;
    }

    /// <summary>
    /// 获取类型名称
    /// </summary>
    /// <param name="obj"></param>
    /// <returns></returns>
    protected string getTypeName(object obj)
    {
        if (obj == null)
        {
            return "";
        }

        switch (Convert.ToInt32(obj))
        {
            case 1: return "QQ";
            case 2: return "MSN";
        }

        return "";
    }

    /// <summary>
    /// 启用
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void but_enable_Click(object sender, EventArgs e)
    {
        string ids = Request.Form["checkboxs"];
        if (ids == null || ids.Trim() == "")
        {
            return;
        }

        foreach (string id in ids.Split(','))
        {
            bll.UpdateEnabled(true, id);
        }
        base.AddLog(2, "启用QQ/MSN管理ID：" + ids);
        loadData();
    }

    /// <summary>
    /// 关闭
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void but_disenable_Click(object sender, EventArgs e)
    {
        string ids = Request.Form["checkboxs"];
        if (ids == null || ids.Trim() == "")
        {
            return;
        }

        foreach (string id in ids.Split(','))
        {
            bll.UpdateEnabled(false, id);
        }
        base.AddLog(2, "关闭QQ/MSN管理ID：" + ids);
        loadData();
    }

    /// <summary>
    /// 删除
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void but_delete_Click(object sender, EventArgs e)
    {
        string ids = Request.Form["checkboxs"];
        if (ids == null || ids.Trim() == "")
        {
            return;
        }

        foreach (string id in ids.Split(','))
        {
            bll.Delete(id);
        }
        base.AddLog(3, "QQ/MSN管理ID：" + ids);
        loadData();
    }
}
